-
Notifications
You must be signed in to change notification settings - Fork 139
chore: setup rivet-engine api tests #3540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
How to use the Graphite Merge QueueAdd the label merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR Review: Setup rivet-engine API TestsThis PR reorganizes and enhances the test suite for rivet-engine's API layer. Overall, this is a solid refactoring that improves test organization and adds better API testing infrastructure. Here's my detailed feedback: ✅ Strengths1. Excellent Code DeduplicationThe creation of shared type definitions in api-types package is a great architectural improvement:
2. Improved Test Organization
3. Comprehensive Test CoverageThe new test files demonstrate thorough coverage:
4. Better Use of Test Infrastructure
🔍 Issues & ConcernsCritical: Cursor Pagination Logic in actors/list.rs (lines 112-120)This logic applies cursor filtering when fetching by actor IDs, but cursor-based pagination doesn't make semantic sense here because you're fetching specific items by ID, not paginating through a list. Problem: When fetching by IDs specifically, the user is asking for specific actors by ID. The cursor comparison uses less than, meaning we want actors created before the cursor timestamp. However, the fanout path (line 186-204) doesn't apply cursor filtering at all—it relies on peer handlers to do it. This creates an inconsistency. Recommendation: Either remove cursor filtering for the actor_ids path (users fetching by ID shouldn't need pagination) or document why cursor pagination is needed when fetching specific IDs. Location: engine/packages/api-public/src/actors/list.rs:112-120 Medium: Missing Error Context in DeletePathIn api-types/src/actors/delete.rs:12-16, DeletePath is missing Debug and documentation. While minor, this impacts debugging (can't easily print the path in logs) and API documentation clarity. Recommendation: Add derive(Debug) and a doc comment explaining this is the path parameter for actor deletion. Medium: Inconsistent Deserialize TraitsIn api-peer/src/internal.rs, you added Deserialize to several response types (lines 13, 41, 49, etc.): CachePurgeResponse, SetTracingConfigResponse, etc. Question: Why do response types need Deserialize? Response types are typically only serialized (for sending to clients), not deserialized. Possible Reason: You might be using these types in tests to parse responses. If so, this is acceptable for test convenience. Consider adding a comment explaining this is for test deserialization or use a feature flag like cfg_attr(test, derive(Deserialize)). Location: engine/packages/api-peer/src/internal.rs:13,41,49,100,109,129,137 Low: Missing Validation Test CasesWhile test coverage is comprehensive, I noticed some edge cases might not be covered:
🎯 Code Quality ObservationsGood Practices ✅
Suggestions
🔒 Security ConsiderationsNo critical security issues found, but worth noting:
📊 Performance ConsiderationsPotential Issue: Fanout EfficiencyIn api-public/src/actors/list.rs:188-197, when using the fanout path, you're fanning out the entire query object to all datacenters, then truncating to limit afterward (line 204). Performance Impact: If you have 10 datacenters and limit=100, each DC might return up to 100 actors, giving you up to 1000 actors to sort and truncate. This is inefficient but probably acceptable for typical use cases. Recommendation: Document this behavior in the function comments (you already have good comments about round trips, this would complement them). 🧪 Test Coverage AssessmentOverall: Excellent
Summary & Recommendations
Overall Assessment: ✅ Approve with minor suggestions This PR significantly improves the test infrastructure and organization. The critical issue with cursor pagination should be addressed, but it's a logic clarification rather than a breaking bug. The deduplication of types and creation of proper test utilities are excellent architectural improvements. Great work on the comprehensive test coverage and following the project's conventions! 🎉 |
More templates
@rivetkit/cloudflare-workers
@rivetkit/db
@rivetkit/framework-base
@rivetkit/next-js
@rivetkit/react
rivetkit
@rivetkit/sql-loader
@rivetkit/engine-runner
@rivetkit/engine-runner-protocol
commit: |
4aa8775 to
ebaa134
Compare
cc6695a to
11133d8
Compare

No description provided.